#pragma once

#include <map>
#include <TinyXML/tinyxml.h>
#include "../MetaTable.h"

namespace ECS
{
	class IXmlParser
	{
	public:
		virtual void parseAttribute(MetaVariable* v, void* instance, const char* attrValue){}
		virtual void parseElement(MetaVariable* v, void* instance, TiXmlElement* element){}
		virtual void writeAttribute(MetaVariable* v, void* insttance, TiXmlElement* element) {}
	};

	class XMLSerializer
	{
		std::map<TypeID, IXmlParser*> _parsers;
	public:
		XMLSerializer();

		void* readFromXml(TiXmlElement* element, MetaClass* cls);
		void writeToXml(TiXmlElement* element, MetaClass* cls, void* instance);
	};

}